from fastapi import FastAPI
from pydantic import BaseModel
import pandas as pd

app = FastAPI(title="DataProfilerX API")

class DataRequest(BaseModel):
    data: dict  # 接收JSON格式数据

@app.post("/profile")
def profile_data(request: DataRequest):
    df = pd.DataFrame([request.data])
    report = DataProfiler(df).generate_report()
    return {"report": report}